package com.heliang.common;

public class URLParse {
	 private String host;
	    private String port;
	    private String part;

	    public URLParse(String url)
	    {
	        int idx = url.indexOf("://");
	        if (idx == -1)
	        {
	            idx = 0;
	        }
	        else
	        {
	            idx += 3;
	        }
	        int idx2 = url.indexOf('/', idx);
	        if(idx2 != -1){
	        	host = url.substring(idx, idx2);
	        }
	        int idx3 = host.indexOf(':');
	        if (idx3 == -1)
	        {
	            port = "80";
	        }
	        else
	        {
	            port = host.substring(idx3 + 1);
	            host = host.substring(0, idx3);
	        }
	        part = url.substring(idx2);
	    }

	    public String getHost()
	    {
	        return host;
	    }

	    public String getPort()
	    {
	        return port;
	    }

	    public String getPath()
	    {
	        return part;
	    }
}
